import React from 'react';

import {Switch, Route, Redirect} from 'react-router-dom'
import {authRoutes} from './routes/routes'
import {isLogin} from './utils/auth'
import './App.less';
import Frame from "./components/Frame";

function App() {
    return (
        isLogin() ?
            <Frame>
                <Switch>
                    {authRoutes.map(route => {
                        return <Route
                            key={route.path}
                            path={route.path}
                            exact={route.exact}
                            render={routeProps => {
                                return <route.component {...routeProps} />
                            }}/>
                    })}
                    <Redirect exact={true} to={authRoutes[0].path} from={'/admin'}/>
                    <Redirect to={'/404'}/>
                </Switch>
            </Frame> :
            <Redirect to={'/login'}/>
    );
}

export default App;
